package assemblers.beans;

import assemblers.interfaces.PersonAssembler;
import infos.PersonInfo;
import model.Person;

import javax.ejb.Stateless;
import java.util.ArrayList;
import java.util.List;

@Stateless(name = "PersonAssembler")
public class PersonAssemblerBean implements PersonAssembler {

    @Override
    public Person assemble(PersonInfo info) {
        Person person = new Person();
        person.setId(info.getId());
        person.setFirstName(info.getFirstName());
        person.setLastName(info.getLastName());
        person.setDescription(info.getDescription());
        return person;
    }

    @Override
    public List<Person> assembleList(List<PersonInfo> personInfos) {
        List<Person> persons = new ArrayList<Person>();
        for (PersonInfo personInfo : personInfos) {
            Person person = assemble(personInfo);
            persons.add(person);
        }
        return persons;
    }
}
